/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package elderberryni2.utils;

import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.joda.time.Period;

/**
 *
 * @author warringer
 */
public class Utils {
    
    public Utils() {
    }
    
    public static String formatTime(double x) {
        int t = new Double(x).intValue();
        Period period = Period.seconds(t).normalizedStandard();
        
        return String.format("%dd:%02dh:%02dm:%02ds", 
                period.getDays(), period.getHours(), period.getMinutes(), period.getSeconds());
    }
    
    public static void wait (int n){
        long t0,t1;
        t0=System.currentTimeMillis();
        do{
            t1=System.currentTimeMillis();
        }
        while (t1-t0<n);
    }
    
    public Font getImpactFont() {
        InputStream is = getClass().getResourceAsStream("/elderberryni2/ressources/Impact_Label.ttf");
        Font font = null;
        try {
            font = Font.createFont(Font.TRUETYPE_FONT, is);
        } catch (FontFormatException ex) {
            Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Utils.class.getName()).log(Level.SEVERE, null, ex);
        }
        font.deriveFont(12f);
        System.out.println(font);
        return font;
    }
    
}
